# import re
# import collections
# import jieba
#
#
# def sort():
#     # 读取文件
#     fn = open('txt/news.txt', 'r')
#     string_data = fn.read()
#     fn.close()
#     # 定义正则表达式匹配模式
#     pattern = re.compile('\t|/|：|_|\n|-|:|;|\)|\(|\?|"')
#     # 将符合模式的字符去除
#     string_data = re.sub(pattern, '', string_data)
#     # 精确模式分词
#     seg_list_exact = jieba.cut(string_data, cut_all=False)
#     object_list = []
#     # 自定义去除词库
#     remove_words = ['，', '。', ' ', '、']
#     # 循环读出每个分词
#     for word in seg_list_exact:
#         # 如果不在去除词库中
#         if word not in remove_words:
#             # 分词追加到列表
#             object_list.append(word)
#     # 词频统计
#     # 对分词做词频统计
#     word_counts = collections.Counter(object_list)
#     # 获取前10最高频的词
#     word_counts_top10 = word_counts.most_common(10)
#     print(word_counts_top10)
